<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>电话编辑</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
		<!--ios是否运行创建快捷启动方式-->
		<meta content="yes" name="apple-mobile-web-app-capable">
		<!--ios顶部通知栏的样式 黑色-->
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<!--遇到数字不让转成电话号码格式-->
		<meta content="telephone=no" name="format-detection">
		<script src="js/remstyle.js"></script>
		<link rel="stylesheet" href="assets/mui/css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="common/css/base.css" />
		<link rel="stylesheet" type="text/css" href="css/min_page.css" />
		<link rel="stylesheet" type="text/css" href="css/sameInfo.css" />
<link rel="stylesheet" type="text/css" href="css/material_video_edit.css" />
		<script type="text/javascript" src="js/vue.js"></script>
		<script type="application/javascript " src="js/jquery-1.7.2.min.js "></script>
		<script src="layer/layer.js"></script>
		<link rel="stylesheet" type="text/css" href="layer/skin/layer.css" />
		<script src="js/config.js"></script>
	</head>
	<style>
		
	</style>

	<body>
		<form>
			<!--顶部-->
			<div class="top">
				<div class="top-one" onclick="javascript :history.back(-1);">
					<span><img src="img_page/right.png"/></span>
				</div>
				<div class="point">
					<img src="img_page/3point.png" />
				</div>
			</div>
			<!--内容信息-->
			<div class="phone_con">
				<div class="phone_title">
					<img src="img_page/video_name.png" />
					<span>视频名称</span>
				</div>
				<div class="phone_info_input" style="margin-bottom: 0;">
					<input id='phone_name' type="text" placeholder="请输入链接名称" name="name" />
				</div>
				<div class="phone_title" style="margin-top: 0;">
					<img src="img_page/video_address.png" />
					<span>链接地址</span>
				</div>
				<div class="import_img" id="import_img">
					<img id="import_video1" class="import_video1" src="img_page/import_video1.png" />
					<img id="import_video2" class="import_video2" src="img_page/import_video2.png" />
					<img class="video_icon" src="img_page/video_icon.png" />
				</div>
				<div class="phone_info_input">
					<input id='phone_number' type="text" placeholder="请输入链接地址" name="phone" />
					<span class="video_import" onclick="video_import()">导入...</span>
				</div>

			</div>

			<!--底部-->

		</form>
		<button id="save_video" onclick="phone_save()" disabled>保存视频</button>

	</body>
	<script type="text/javascript">
		function phone_save() {

			console.log(4444)
			var video_name = document.getElementById("phone_name").value;
			var url = document.getElementById("phone_number").value;
			console.log(video_name)
			if(!video_name || !url) {
				layer.msg("请输入完整信息")
			} else if(video_name.length > 16) {
				layer.msg("视频名字不能超过16位")
			} else {
				$.ajax({
					type: "get",
					url: v_url + "/wechat/material/saveVideo",
					data: {
						url: url,
						video_name: video_name,
						c_user_id:c_user_id
					},
					async: true,
					success: function(res) {

						if(res.code == 200) {
							console.log(2222)
							layer.msg("保存成功", function() {
								window.location.reload()
							})

						} else {
							console.log(333)
							layer.msg("保存失败")
						}
					}
				});
			}

		}

		function video_import() {
			console.log(2222)
			var url = document.getElementById("phone_number").value;
			$.ajax({
				type: "get",
				url:  v_url +"/wechat/material/importVideo",
				data: {
					url: url,
					c_user_id:c_user_id
				},
				async: true,
				success: function(res) {

					if(res.code == 200) {
						console.log(2222)
						var new_url = res.data;
						url = new_url
						console.log(url);
						document.getElementById("save_video").removeAttribute("disabled");
						document.getElementById("import_img").style.display = "block";
						document.getElementById("import_video1").style.display = "block";
						document.getElementById("import_video2").style.display = "none";
					} else {
						console.log(333)
						layer.msg("视频格式有误");
						document.getElementById("save_video").removeAttribute("disabled");
						document.getElementById("import_img").style.display = "block";
						document.getElementById("import_video2").style.display = "block";
						document.getElementById("import_video1").style.display = "none";
					}
				},
				error:function(res){
					console.log(5555)
				}
			});
		}
	</script>

</html>